<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>纯JS - 单击+1按钮</title>
</head>

<body>
    <button onclick="myClick()">单击我</button>
    <p>单击了<span id="clickCount">0</span>次</p>
    <h3>JS</h3>
    <script>
        let count = 0; // 初始化计数器为0
        const clickCount = document.getElementById("clickCount"); // 获取显示次数的元素
        function myClick() {
            count++; // 每次点击计数器加1
            clickCount.innerHTML = count; // 将计数器的值显示在页面上
        }
    </script>
</body>

</html>